// src/plugins/baidu-tongji.ts
export function setupBaiduTongji() {
  // 仅在生产环境加载百度统计
  if (import.meta.env.DEV || typeof window === 'undefined') {
    return;
  }

  const _hmt = (window as any)._hmt || [];
  (window as any)._hmt = _hmt;

  const script = document.createElement('script');
  script.src = 'https://hm.baidu.com/hm.js?dae084ef9d2e4373d1cdca6fbad23b89';
  script.async = true;

  const firstScript = document.getElementsByTagName('script')[0];
  if (firstScript?.parentNode) {
    firstScript.parentNode.insertBefore(script, firstScript);
  } else {
    document.head.appendChild(script);
  }
}
